﻿#region Header

/*
Behavioral Rating of Dancing Human Crowds based on Motion Patterns
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System;
using System.Collections.Generic;
using Emgu.CV;
using Emgu.CV.Structure;

#endregion

namespace paravili.Steps {
	/// <summary>
	/// returns null if the images occures more than ones
	/// </summary>
	public class ThrowEqualImagesAway : ProcessStepWithMeasurement<Image<Bgr, Byte>> {
		#region Public Properties

		public Image<Bgr, Byte> LastImage { get; private set; }

		#endregion

		#region Public Methods
        List<double> rates = new List<double>();
        int goodcnt = 0;
		protected override Image<Bgr, byte> OnProcess(Image<Bgr, byte> toProcess) {
			if (LastImage == null) {
				LastImage = toProcess;
			}
			else if (LastImage == toProcess) {
                rates.Add(1d / goodcnt);
                goodcnt = 0;
				return null;
			}
            goodcnt++;
			LastImage = toProcess;
			return toProcess;
			;
		}

		#endregion
	}
}